package com.zmzncs.lmtc.module.shop.service.impl;

import com.zmzncs.lmtc.module.shop.dao.ShopGoodsFileDao;
import com.zmzncs.lmtc.module.shop.pojo.shop_goods.ShopGoods;
import com.zmzncs.lmtc.module.shop.dao.ShopGoodsMapper;
import com.zmzncs.lmtc.module.shop.pojo.shop_goods.ShopGoodsDTO;
import com.zmzncs.lmtc.module.shop.pojo.shop_goods_file.ShopGoodsFileDTO;
import com.zmzncs.lmtc.module.shop.pojo.shop_ticket.ShopTicketDTO;
import com.zmzncs.lmtc.module.shop.service.ShopGoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 商户-商品 服务实现类
 * </p>
 *
 * @author 高博文
 * @since 2021-05-20
 */
@Service
public class ShopGoodsServiceImpl extends ServiceImpl<ShopGoodsMapper, ShopGoods> implements ShopGoodsService {

    @Autowired
    ShopGoodsMapper shopGoodsMapper;
    @Autowired
    ShopGoodsFileDao shopGoodsFileDao;

    /**
     * 详情
     */
    @Override
    public ShopGoodsDTO getById(Long id) {
        ShopGoodsDTO shopGoodsDTO = shopGoodsMapper.getById(id);
        List<ShopGoodsFileDTO> shopGoodsFileDTOList = shopGoodsFileDao.getFileByGoodsId(id);
        List<String> fileList = shopGoodsFileDTOList.stream().map(ShopGoodsFileDTO::getFileUrl).collect(Collectors.toList());
        shopGoodsDTO.setFileList(fileList);

        return shopGoodsDTO;
    }

}
